package com.yoomiito.app.widget.dialog

import android.app.Activity
import android.net.Uri
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.webkit.ValueCallback
import android.widget.Button
import com.yoomiito.app.R
import com.yoomiito.app.utils.ImageUtils

class CameraDialog(val activity: Activity, var mFilePathCallback: ValueCallback<Array<Uri>>?=null):BaseDialog(activity) {

    override fun setView(): View {
        val view = LayoutInflater.from(context).inflate(R.layout.dialog_camera,null,false)
        view.findViewById<Button>(R.id.camera).setOnClickListener {
            ImageUtils.goToCamera(activity,false)
            dismiss()
        }
        view.findViewById<Button>(R.id.album).setOnClickListener {
            ImageUtils.goToAlbum(activity)
            dismiss()
        }
        view.findViewById<Button>(R.id.cancel).setOnClickListener {
            if (mFilePathCallback!=null){
                mFilePathCallback?.onReceiveValue(null)
                mFilePathCallback = null
            }
            dismiss()
        }
//        setOnDismissListener {
//            if (mFilePathCallback!=null){
//                mFilePathCallback?.onReceiveValue(null)
//                mFilePathCallback = null
//            }
//        }
        setCanceledOnTouchOutside(false)
        setmGravity(Gravity.BOTTOM)
        setWidthPercent(1.0)
        return view
    }

}